package com.example.kafka.controller;

import com.example.kafka.service.PartitionKeyLeakService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * 低基数分区键 Controller
 */
@RestController
public class PartitionKeyLeakController {
    @Autowired
    private PartitionKeyLeakService service;

    @PostMapping("/sendStatus")
    public String send1(@RequestParam String status, @RequestBody String msg) {
        service.send1(status, msg);
        return "ok";
    }

    @PostMapping("/sendTime")
    public String send2(@RequestBody String msg) {
        service.send2(LocalDateTime.now().toString(), msg);
        return "ok";
    }

    @PostMapping("/sendNullKey")
    public String send3(@RequestBody String msg) {
        service.send3(msg);
        return "ok";
    }

    @PostMapping("/sendHotKey")
    public String send4(@RequestParam String productId, @RequestBody String msg) {
        service.send4(productId, msg);
        return "ok";
    }

    @PostMapping("/sendCustomPartition")
    public String send5(@RequestParam String key, @RequestBody String msg) {
        service.send5(key, msg);
        return "ok";
    }
}
